{extend name="common/base"}
{block name='title'}优惠券页面{/block}
{block name='body-type'}coupon_index{/block}
{block name="content"}
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">优惠券管理</div>


                            </div>
                            <div class="widget-body  am-fr">

                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button type="button" class="am-btn am-btn-default am-btn-success" onclick="window.location.href='add'"><span class="am-icon-plus"></span> 新增</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>


                                <div class="am-u-sm-12">
                                    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                        <thead>
                                            <tr>
                                                <th style="font-size: 9px;">序号</th>
                                                <th style="font-size: 9px;">名称</th>
                                                <th style="font-size: 9px;">优惠券金额</th>
                                                <th style="font-size: 9px;">发送起始日期</th>
                                                <th style="font-size: 9px;">发送结束日期</th>
                                                <th style="font-size: 9px;">使用起始日期</th>
                                                <th style="font-size: 9px;">使用结束日期</th>
                                                <th style="font-size: 9px;">优惠券描述</th>
                                                <th style="font-size: 9px;">推荐状态</th>
                                                <th style="font-size: 9px;">操作</th>  
                                            </tr>
                                        </thead>
                                        <tbody id="ajax-body">
                                            {volist name="couponlist" id="vo"  key="k"}
                                            <tr class="gradeX">
                                                <td style="font-size: 8px;">{$k}</td>
                                                <td style="font-size: 8px;">{$vo.coupon_name}</td>
                                                <td style="font-size: 8px;">{$vo.coupon_money}</td>
                                                <!-- <td style="font-size: 8px;">{$vo.min_amount}</td>
                                                <td style="font-size: 8px;">{$vo.max_amount}</td> -->
                                                <td style="font-size: 8px;">{$vo.send_start_time}</td>
                                                <td style="font-size: 8px;">{$vo.send_end_time}</td>
                                                <td style="font-size: 8px;">{$vo.use_start_time}</td>
                                                <td style="font-size: 8px;">{$vo.use_end_time}</td>
                                                <td style="font-size: 8px;" width="10%" style="overflow: hidden;text-overflow:ellipsis;
                                                white-space: nowrap;">{$vo.coupon_data}</td>
                                                <td class="am-text-middle" width="8%">
                                                    <div class="tpl-table-black-operation">
                                                        <button class="tpl-table-black-operation-del" onclick="get_status(this)" style="color:grey;border-radius:15px;outline-color:transparent;">{eq name='$vo.status' value="0"}
                                                            未推荐
                                                            {else/}
                                                            已推荐
                                                            {/eq}</button>  
                                                        <input type="hidden" id="get_status" value="{$vo.id}">
                                                    </div>
                                                </td>
                                                <td style="font-size: 8px;width: 15%;">
                                                    <div class="tpl-table-black-operation">
                                                        <a href="{:Url('admin/coupon/edit')}?id={$vo.id}" style="float:left;">
                                                            <i class="am-icon-pencil"></i> 编辑
                                                        </a> &nbsp;
                                                        <a href="{:Url('admin/coupon/delete')}?id={$vo.id}" class="tpl-table-black-operation-del" style="float:left;">
                                                            <i class="am-icon-trash"></i> 删除
                                                        </a>
                                                    </div>
                                                </td>
                                                
                                            </tr>
                                            {/volist}
                                            <!-- more data -->
                                        </tbody>
                                    </table>
                                </div>
                                <div class="am-u-lg-12 am-cf">
                                    <div class="am-fr" id="ajax-page">
                                        {$page}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {/block}
        {block name="footer-js"}
        <script>
        function get_status(obj){
            var coupon_id = $(obj).next('input').val();
            $.ajax({
                url:"{:Url('admin/coupon/get_status')}",
                type:"post",
                data:{coupon_id:coupon_id},
                dataType:"json",
                success:function(data){
                    console.log(data);
                    if(data==0){
                        $(obj).html('未推荐');
                    }else{
                        $(obj).html('已推荐');
                    }
                }
            });
        }
        </script>
        {/block}